﻿<Window x:Class="_12.BindToList.SimpleBinding"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p11="clr-namespace:_11.DataBinding;assembly=11.DataBinding"
        Title="SimpleBinding" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="134" Width="352">
    <Window.Resources>
    </Window.Resources>
    <Grid Name="gridPerson">
        <Grid.Resources>
            <Style TargetType="Label">
                <Setter Property="FontWeight" Value="ExtraBlack"/>
                <Setter Property="HorizontalContentAlignment" Value="Right"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
            </Style>
            <Style TargetType="TextBox">
                <Setter Property="Margin" Value="5"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Background" Value="LightCyan"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="BorderBrush" Value="black"/>
            </Style>
            <Style TargetType="Button">
                <Setter Property="Margin" Value="5"/>
                <Setter Property="Background" Value="LawnGreen"/>
            </Style>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="1.5*" />
            <ColumnDefinition Width="1.5*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Label Grid.Row="0" Grid.Column="0" Content="Name: "  />
        <Label Grid.Row="1" Grid.Column="0" Content="Age: "  />
        <TextBox Grid.Column="1" Text="{Binding Path=Name}" Grid.ColumnSpan="2"  />
        <TextBox Grid.Row="1" Grid.Column="1"  Grid.ColumnSpan="2" 
                 ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}">
            <TextBox.Text>
                <Binding Path="Age" >
                    <Binding.ValidationRules>
                        <p11:AgeValidator Min="0" Max="100"/>
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        <Button Name="btnNext" Content="Next" Grid.Column="1" Grid.Row="2"  
                Click="btnNext_Click"/>
        <Button Name="btnPrevious" Content="Previous" Grid.Column="2" Grid.Row="2" 
                Click="btnPrevious_Click"/>
    </Grid>
</Window>
